﻿
namespace Settings.NET.UnitTests
{
    using Microsoft.VisualStudio.TestTools.UnitTesting;

    using Settings.NET.UnitTests.Helpers;

    [TestClass]
    public class ConversionTests
    {
        [TestMethod]
        public void IsValueType_Int_ReturnsTrue()
        {
            var isValueType = ConversionHelper.IsValueType(5);
            Assert.IsTrue(isValueType);
        }

        [TestMethod]
        public void IsValueType_IntType_ReturnsTrue()
        {
            var isValueType = ConversionHelper.IsValueType<int>();
            Assert.IsTrue(isValueType);
        }        

        [TestMethod]
        public void IsStruct_PassStruct_ReturnsTrue()
        {
            var value = new PersonStruct();
            var isStruct = ConversionHelper.IsStruct(value);
            Assert.IsTrue(isStruct);
        }

        [TestMethod]
        public void IsStruct_PassInt_ReturnsFalse()
        {
            var isStruct = ConversionHelper.IsStruct(5);
            Assert.IsFalse(isStruct);
        }

        [TestMethod]
        public void IsString_PassString_ReturnsTrue()
        {
            var isString = ConversionHelper.IsString("Hello");
            Assert.IsTrue(isString);
        }
        
        [TestMethod]
        public void IsString_PassInt_ReturnsFalse()
        {
            var isString = ConversionHelper.IsString(5);
            Assert.IsFalse(isString);
        }

        [TestMethod]
        public void IsNullableType_PassNullableType_ReturnsTrue()
        {
            int? i = 5;
            var isNullableType = ConversionHelper.IsNullableType(i);
            Assert.IsTrue(isNullableType);
        }

        [TestMethod]
        public void IsNullableType_PassReferenceType_ReturnsFalse()
        {
            var personClass = new PersonClass();
            var isNullableType = ConversionHelper.IsNullableType(personClass);
            Assert.IsFalse(isNullableType);
        }

        [TestMethod]
        public void IsNullableType_PassValueType_ReturnsFalse()
        {
            const int I = 5;
            var isNullableType = ConversionHelper.IsNullableType(I);
            Assert.IsFalse(isNullableType);
        }
    }
}